/***
 * @title: sys_log Controller file
 * @author: seasonszx dev
 * @datetime: 2018-01-24 14:08:07
 * @version: 1.0.0
 */
package com.zx.platform.zanadu.manager.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zx.platform.zanadu.manager.pojo.SysLog;
import com.zx.platform.zanadu.manager.service.SysLogService;

@Controller
@RequestMapping("/sysLog")
public class SysLogController {
	
	@Autowired
	@Qualifier("sysLogServiceImpl")
	private SysLogService sysLogService;
	
	@Autowired
	@Qualifier("sysLogServiceImplMongodb")
	private SysLogService sysLogServiceImplMongodb;
	
	// 基本信息新增
	@RequestMapping(value = "/add",
			method = {RequestMethod.POST})
	@ResponseBody
	public Map<String, Object> add(@RequestBody SysLog info) {
		Map<String, Object> map = new HashMap<String, Object>();
		int count = sysLogServiceImplMongodb.insert(info);
		map.put("count", count);
		return map;
	}
	
	// 基本信息修改
	@RequestMapping(value = "/upd",
			method = {RequestMethod.POST})
	@ResponseBody
	public Map<String, Object> upd(@RequestBody SysLog info) {
		Map<String, Object> map = new HashMap<String, Object>();
		int count = sysLogServiceImplMongodb.update(info);
		map.put("count", count);
		return map;
	}

	// 主键删除
	@RequestMapping(value = "/del",
			method = {RequestMethod.POST})
	@ResponseBody
	public Map<String, Object> del(String primarykey) {
		Map<String, Object> map = new HashMap<String, Object>();
		int count = sysLogServiceImplMongodb.deleteByPrimaryKey(primarykey);
		map.put("count", count);
		return map;
	}
	
	// 主键查询对象
	@RequestMapping(value = "/selectone",
			method = {RequestMethod.POST,RequestMethod.GET})
	@ResponseBody
	public Map<String, Object> selectone(String primarykey) {
		Map<String, Object> map = new HashMap<String, Object>();
		SysLog info = sysLogServiceImplMongodb.selectByPrimaryKey(primarykey);
		map.put("info", info);
		return map;
	}
	
	// 全查集合
	@RequestMapping(value = "/selectall",
			method = {RequestMethod.POST,RequestMethod.GET})
	@ResponseBody
	public Map<String, Object> selectall() {
		Map<String, Object> map = new HashMap<String, Object>();
		List<SysLog> list = sysLogServiceImplMongodb.selectAll();
		map.put("list", list);
		return map;
	}
	
	// 条件查询集合
	@RequestMapping(value = "/search",
			method = {RequestMethod.POST,RequestMethod.GET})
	@ResponseBody
	public Map<String, Object> search(@RequestBody Map<String, Object> paramap) {
		Map<String, Object> map = new HashMap<String, Object>();
		List<SysLog> list = sysLogServiceImplMongodb.selectByCondition(paramap);
		map.put("list", list);
		return map;
	}
	
	// 分页条件查询集合
	@RequestMapping(value = "/searchpage",
			method = {RequestMethod.POST,RequestMethod.GET})
	@ResponseBody
	public Map<String, Object> searchpage(@RequestBody Map<String, Object> paramap) {
		Map<String, Object> map = new HashMap<>();
		List<SysLog> list = sysLogServiceImplMongodb.selectByPageCondition(paramap);
		map.put("list", list);
		return map;
	}
}
